package net.zretc.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;

/**
 * 订单实体类
 * 用于存储用户订单信息
 */
@TableName("`order`") // 使用反引号因为order是MySQL关键字
public class Order {

    // 订单ID，主键，自增
    @TableId(type = IdType.AUTO)
    private Integer orderId;

    // 用户ID
    private Integer userId;

    // 商品ID
    private Integer productId;

    // 商品数量
    private Integer quantity;

    // 下单时间
    private Date createTime;

    // 无参构造函数
    public Order() {
    }

    // 有参构造函数
    public Order(Integer userId, Integer productId, Integer quantity) {
        this.userId = userId;
        this.productId = productId;
        this.quantity = quantity;
        this.createTime = new Date();
    }

    // Getter 和 Setter 方法
    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getProductId() {
        return productId;
    }

    public void setProductId(Integer productId) {
        this.productId = productId;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "Order{" +
                "orderId=" + orderId +
                ", userId=" + userId +
                ", productId=" + productId +
                ", quantity=" + quantity +
                ", createTime=" + createTime +
                '}';
    }
}